<!--
 * @Description: 策划会议
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-08-18 10:35:57
 * @LastEditTime: 2023-03-13 15:19:30
 * @FilePath: \cscec-pms-admin\src\views\project\projectPlanningMeeting\index.vue
-->
<template>
  <base-breadcrumb>
    <MeetingList
      ref="meetingList"
      :meeting-type="'16'"
      :add-path="addPath"
      :operation-path="operationPath"
      :btn-permission="btnPermission"
      :search-option="searchOption"
      :columns="columns1"
      use-export
    >
      <template
        slot="operation"
        slot-scope="record"
      >
        <a
          v-if="record.record.meetingStatus === '20' || record.record.meetingStatus === '30' || record.record.meetingStatus === '40'"
          v-btnPermission="btnPermission.view"
          @click="handleOperation(record, 'view')"
        >查看</a>
        <a
          v-if="(record.record.meetingStatus === '20' || record.record.meetingStatus === '30' || record.record.meetingStatus === '40') && hideBuquBtn()"
          v-btnPermission="btnPermission.upload"
          @click="handleOperation(record, 'upload')"
        >上传策划资料</a>
        <a
          v-if="record.record.meetingStatus === '20' && hideBuquBtn() && isCreateUser(record)"
          v-btnPermission="btnPermission.delete"
          @click="handleOperation(record, 'delete')"
        >删除</a>
        <!-- 一个人只能填一次还需要实现 -->
        <a
          v-if="(record.record.meetingStatus === '30' || record.record.meetingStatus === '40') && record.record.isReviewCommentsButton !== 1 && hideBuquBtn()"
          v-btnPermission="btnPermission.review"
          @click="handleOperation(record, 'review')"
        >评审意见</a>
      </template>
    </MeetingList>
  </base-breadcrumb>
</template>
<script>
import MeetingList from '@/components/Meeting/MeetingList'
import { btnPermission, searchOption, columns1 } from './model.js'
import training from '@/api/design/training'
export default {
  name: 'projectPlanningMeeting',
  components: {
    MeetingList
  },
  data() {
    return {
      // 新增页面路径
      addPath: '/project/planningMeeting/add',
      // 操作页面路径
      operationPath: '/project/planningMeeting/operation',
      // 按钮权限
      btnPermission,
      // 搜索项
      searchOption,
      // 表头
      columns1
    }
  },
  filters: {
    meetingLevel (val) {
      return moment(date).fromNow()
    }
  },
  methods: {
    /**
     * @description: 会议操作
     * @param {object} record
     * @param {string} pageType
     * @return {void}
     */
    handleOperation({ record }, pageType) {
      switch (pageType) {
        //删除
        case 'delete':
          let vm = this
          this.$confirm({
            title: '温馨提示',
            content: '确定是否删除数据？',
            okText: '确认',
            okType: 'danger',
            cancelText: '取消',
            onOk() {
            return training.deleteByPrimaryKey(record.id)
              .then((res) => {
                console.log(res)
                if(res.code === vm.SUCCESS_CODE){
                  vm.$message.success('删除成功！')
                  vm.$refs.meetingList.search()
                }else{
                  vm.$message.warning('删除失败！')
                }
              })
            }
          })
          break
        // 查看
        case 'view':
          let type = ''
          switch (record.meetingStatus) {
            //待开始
            case '20':
              type = 'detail'
              break
            // 进行中
            case '30':
              type = 'enter'
              break
            default:
              type = 'view'
          }
          // 其他操作
          this.$router.push({
            path: this.operationPath,
            query: {
              id: record.id,
              meetingName: record.meetingName,
              pageType: type
            }
          })
          break
        default:
          // 其他操作
          this.$router.push({
            path: this.operationPath,
            query: {
              id: record.id,
              meetingName: record.meetingName,
              pageType
            }
          })
      }
    },
    /**
     * @description: 是否创建人
     * @param {object} record
     * @return {void}
     */
    isCreateUser({ record }) {
      return record.createUserId === this.$store.state.user.userInfo.id
    }
  }
}
</script>
<style lang="less" scoped></style>
